<?php
class Util_Cookie{
    public static function set_cookie($user_info) {
        if(empty($user_info)){
            return false;
        }
        $apf = APF::get_instance();
        $str = $user_info['user_id'] . "\t" .$user_info['user_code']."\t".base64_encode($user_info['user_name'])."\t".$user_info['user_email']."\t" . time();
        $def_key = $apf->get_config('ecrypt_str');

        $cookie_str = Util_Encrypt::encrypt($str,$def_key);
        $cookie_name = $apf->get_config('AuthCookieName');
        $domain = $apf->get_config('cookie_domain');
        $path = $apf->get_config('cookie_path');
        $expire=86400;
        return setcookie($cookie_name, $cookie_str, $expire ? time() + intval($expire) : 0, $path, $domain, false, false);
    }
}